import { readFileSync } from 'fs';
import * as yaml from 'js-yaml';
import { join } from 'path';

const configFilenameMap = {
    development: 'dev.config.yaml',
    production: 'prod.config.yaml'
}
export default async () => {
    const YAML_CONFIG_FILENAME = configFilenameMap[process.env.NODE_ENV] || 'prod.config.yaml';
    const configFilePath = join(process.cwd(), 'assets', YAML_CONFIG_FILENAME);
    const config = readFileSync(configFilePath, {
        encoding: 'utf-8'
    });

    return yaml.load(config);
};